<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        html,body{
            height: 100%;
        }
        body{

          display: flex;

            
            background-image:url(./img/bg.jpeg); 
            background-repeat: no-repeat;
            background-size: cover;
        }
        .outer{
            margin: auto;
            width: 30%;
            height: 50%;
            background-color: red;
            border-radius: 5%;
            overflow: hidden;
            text-align: center;
        }
        .outer>.top{
            height: 20%;
            background-color: #87cefa;
            color: white;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 30px;
        }
        .outer>.bottom{
            height: 80%;
            background-color: white;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 10% 0;
            box-sizing: border-box;
            justify-content: space-between;
        }
        .outer>.bottom>input{
            width: 70%;
            height: 20%;
            text-indent: 5%;
            outline: none;
        }
        .outer>.bottom>section{
            width: 70%;
            display: flex;
            justify-content: space-between;
        }
        .outer>.bottom>.login{
            width: 30%;
            color: white;
            text-indent: 0;
            background-color: #5be85b;
            border: none;
        }
    </style>
</head>
<body>
    <div class="outer">
        <div class="top">欢迎登录后台管理系统</div>
        <div class="bottom">
            <input class="phone" type="text" name="" id="" placeholder="输入用户名">
            <input class="mima" type="password" name="" id="" placeholder="输入密码">
            <section>
                <a href="./register.html">去注册</a>
                <a href="#">忘记密码</a>
            </section>
           <input class="login" type="button" value="登录">
        </div>
    </div>
</body>
</html>
<script src="./axios.min.js"></script>
<script>
    var phone=document.querySelector('.phone')
    var mima=document.querySelector('.mima')
    var login=document.querySelector('.login')
    login.onclick=function(){
    
      if(  /^1[3-9]\d{9}$/.test(phone.value)){
        axios.post('/user/login',{phone:phone.value,mima:mima.value}).then(
            (res)=>{
                location.href='/index.html'
                console.log(res.data)
                console.log(JSON.stringify(res.data.userinfo))
                localStorage.setItem('yonghu',JSON.stringify(res.data.userinfo))
            }
        )
      }else{
        alert('请输入正确的手机号')
      }
    }
</script>